<template>
	<view class="shopCarMenuList">
		<view class="shopCarMenuList-item" v-for="(items,idxs) of shopCarMenuList" :key="idxs">
			<!-- 图片 -->
			<u-image class="img" width="203rpx" height="203rpx" :src="imgUrl(items.content.main.pic)"></u-image>

			<!-- 容器 -->
			<view class="box">
				<!-- 主菜 -->
				<view class="bold">
					<template v-if="!items.content.side.id && !items.content.vegetables.id && !items.content.staple.id && !items.content.other.length">
						主菜:
						<template v-if="items.content.main.description">
							{{items.content.main.title}} + {{items.content.main.description}}
						</template>
						<template v-else>
							{{items.content.main.title}}
						</template>
					</template>
					
					<template v-else>
						主菜:{{items.content.main.title}}
					</template>
				</view>

				<!-- 副菜 -->
				<view class="thin" v-if="items.content.side.id">
					副菜:{{items.content.side.title}}
				</view>

				<!-- 青菜 -->
				<view class="thin" v-if="items.content.vegetables.id">
					青菜:{{items.content.vegetables.title}}
				</view>

				<!-- 小食 -->
				<view class="thin" v-if="items.content.staple.id">
					小食:{{items.content.staple.title}}
				</view>
				
				<!-- 其他 -->
				<view class="thin" v-if="items.content.other.length">
					其他:<span v-for="(otherItem, otherIndex) of items.content.other" :key="otherIndex">{{ otherItem.name +' '}}</span>
				</view>

			</view>

			<!-- 删除按钮 -->
			<u-icon @click="showDelete(idxs)" class="del" name="close" size="40"></u-icon>
		</view>
		
		<!-- 删除弹窗 -->
		<u-modal v-model="show" content="确定要删除该订单吗?" @confirm="confirm" ref="uModal" :async-close="true" show-cancel-button="true"></u-modal>

	</view>
</template>
<script>
	import {
		createNamespacedHelpers
	} from 'vuex'
	const {
		mapState,
		mapMutations
	} = createNamespacedHelpers('unSignModule')
	
	import {imgUrl} from "@/utils/imgUrl.js"
	
	export default {
		data() {
			return {
				show:false,//是否显示弹窗
				current:0//要删除的索引值
			}
		},
		computed:{
			...mapState(["shopCarMenuList"])
		},
		methods:{
			...mapMutations(["REMOVE_item_shopCarMenuList"]),
			showDelete(idxs){//显示删除弹窗
				this.show = true
				this.current = idxs
			},
			confirm(){//确定删除
				this.REMOVE_item_shopCarMenuList(this.idxs)
				this.show = false;
			}
		}
	}
</script>
<style lang="scss" scoped>
	.shopCarMenuList {
		background-color: #f8f3f3;
		padding-bottom: 450rpx;

		.shopCarMenuList-item {
			margin-bottom: 20rpx;
			background-color: #ffffff;
			position: relative;
			padding: 20rpx;
			box-sizing: border-box;
			border-radius: 20rpx;
			display: flex;
			
			.img{
				border-radius: 20rpx;
				overflow: hidden;
			}

			.box{
				flex: 1;
				padding: 0 20rpx;
				box-sizing: border-box;
			}
			
			.del{
				position: absolute;
				top: 20rpx;
				right: 20rpx;
			}
		}
	}
</style>
